package com.tangl.demo.controller.mongo.base;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * @author: TangLiang
 * @date: 2020/12/9 16:06
 * @since: 1.0
 */
@Service
@Slf4j
public class BookMongoDbService {

    //注入新的CURD操作类
    @Autowired
    private BookMongoDbDao bookMongoDbDao;

    /**
     * 保存对象
     *
     * @param book
     * @return
     */
    public String saveObj2(Book book) {
        book.setCreateTime(new Date());
        book.setUpdateTime(new Date());
        //调用bookMongoDbDao父类中的添加方法
        bookMongoDbDao.save(book);
        return "添加成功";
    }

}
